from itertools import islice
class Fab:
    def __init__(self, max):
        self.max = max

    def __iter__(self):
        self.a, self.b = 0, 1
        return self

    def __next__(self):
        fib = self.a
        if fib > self.max:
            raise StopIteration
        self.a, self.b = self.b, self.a + self.b
        return fib

if '__main__' == __name__:
    s = Fab(100)
    try:
        for n in islice(s, 2, 3):
            print(n)
    except StopIteration:
        print('finished')